/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.cef.generator.repository.base;

import com.inspur.edp.caf.generator.compileunit.CompileUnitGenerator;
import com.inspur.edp.caf.generator.compileunit.CompileUnitGeneratorContext;
import com.inspur.edp.cef.generator.overall.CefGeneratorContext;

public class CefRepositoryGenerstor extends CompileUnitGenerator {
    private CefGeneratorContext cefGenCtx;

    public CefRepositoryGenerstor(CefGeneratorContext cefGenCtx) {
        this.cefGenCtx = cefGenCtx;
    }


    @Override
    protected CompileUnitGeneratorContext createProjectInfoContext() {
        cefGenCtx.setRepoGenContext(getRepoGenCtx());
        return cefGenCtx.getRepoGenContext();
    }

    protected CefRepoGenCtx getContext() {
        return (CefRepoGenCtx) super.getContext();
    }

    protected CefRepoGenCtx getRepoGenCtx() {
        CefRepoGenCtx ctx = new CefRepoGenCtx(cefGenCtx);
        ctx.setDefaultNameSpace(getPackageName());
        return ctx;
    }

    @Override
    protected String getPackageName() {
        return String.format("%1$s.repository",
                cefGenCtx.getDataTypeNamespace());
    }


//
//	@Override
//	protected String  getDefaultNamespace()
//	{
//		return getAssemblyName();
//	}
//
//	@Override
//	protected GenerateType  getGenerateType()
//	{
//		return GenerateType.LocalFile;
//	}

    @Override
    protected String getFilePath() {
        return cefGenCtx.getMetadataJitContext().getCodePath();
    }


    @Override
    protected void afterGenerate() {
        super.afterGenerate();
        // todo:wj-RepopsitoryAssembly
        //cefGenCtx.RepopsitoryAssembly = ReflectionUtil.GetAssemblyFromPath(cefGenCtx.GeneratePath, getAssemblyName());
        //         cefGenCtx.RepoAssemblerType = cefGenCtx.RepopsitoryAssembly.GetType(Context.RootEntityAssemblerType.getFullName());
    }

    @Override
    protected void beforeGenerate() {
        super.beforeGenerate();
//        cefGenCtx.getMetadataJitContext().getCoreModuleGenerator().addCompileUnitGenrator(this);
//        super.setRefProjectGen(cefGenCtx.getMetadataJitContext().CoreGenerator);
    }

    private void setConctexTypes() {

    }
}
